###Project setup###
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(libPortal)
ADD_DEFINITIONS(-DPORTALDLL)
IF(UNIX)  #assume linux for now.
  ADD_DEFINITIONS(-DLINUX)
ENDIF(UNIX)
#SET(CMAKE_VERBOSE_MAKEFILE TRUE)

###includes###
INCLUDE(${CMAKE_ROOT}/Modules/FindBoost.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/FindSDL.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)

###find all packages###
FIND_PACKAGE(Boost REQUIRED)
IF(WIN32)
  SET(SDL_BUILDING_LIBRARY TRUE)
ENDIF(WIN32)
FIND_PACKAGE(SDL)

###configure project###
SET(BUILD_EXAMPLE TRUE)
IF(NOT OPENGL_FOUND)
  SET(BUILD_EXAMPLE FALSE)
  MESSAGE(STATUS "OpenGL not found - not building example app.")
ELSEIF(NOT SDL_FOUND)
  SET(BUILD_EXAMPLE FALSE)
  MESSAGE(STATUS "SDL not found - not building example app.")
ENDIF(NOT OPENGL_FOUND)

IF(NOT Boost_FOUND)
  MESSAGE(SEND_ERROR "Boost is required to compile this library")
ENDIF(NOT Boost_FOUND)

###build project###
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
IF(BUILD_EXAMPLE)
  ADD_SUBDIRECTORY(example)
ENDIF(BUILD_EXAMPLE)
